home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / FRIENDS.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  832b  |  31 lines

  1. ' FRIENDS.BAS
  2. ' This program demonstrates the INPUT# statement.
  3.  
  4. CLS
  5.  
  6. OPEN "FRIENDS.TXT" FOR OUTPUT AS #1  ' open file for output
  7.  
  8. PRINT "Enter the names of four of your friends"
  9. PRINT
  10.  
  11. FOR i% = 1 TO 4                      ' loop 4 times
  12.     INPUT "Friendly name:  ", pal$   ' each time get name from user
  13.     WRITE #1, pal$                   '   and write it to disk
  14. NEXT i%
  15.  
  16. CLOSE #1                             ' close the file
  17.  
  18. OPEN "FRIENDS.TXT" FOR INPUT AS #1   ' reopen the file for input
  19.  
  20. PRINT
  21. PRINT "You entered the following names:"
  22. PRINT
  23.  
  24. FOR i% = 1 TO 4                      ' loop 4 times
  25.     INPUT #1, pal$                   ' each time get name from file
  26.     PRINT pal$                       '   and display it on screen
  27. NEXT i%
  28.  
  29. CLOSE #1                             ' close the file
  30.  
  31.